package top.codedance.iotp.client.manage.net.configuration;

import top.codedance.iotp.common.entity.CliCmdEntity;

import java.util.ArrayList;
import java.util.List;

public class CliCmdOptionsConfig {
    public static List<CliCmdEntity> getCmds(){
        List<CliCmdEntity> cmds = new ArrayList<>();
        cmds.add(new CliCmdEntity(true,"d", "deviceId", true, "Unique device id.", String.class, true));
        cmds.add(new CliCmdEntity(false,"h", "host", true, "Tcp server host.", Integer.class, true));
        cmds.add(new CliCmdEntity(false,"p", "port", true, "Tcp server port.", Integer.class, true));
        cmds.add(new CliCmdEntity(false,"l", "logLevel", true, "enable debug mode.", String.class, true));
        cmds.add(new CliCmdEntity(false,"b", "enableLoadBlance", false, "Enable loadBlance.", Boolean.class, true));
        cmds.add(new CliCmdEntity(false,"t", "lbType", true, "LoadBlance type: 1、AUTO, 2、CYCLE, 3、RANDOM, 4、WEIGHT.", Integer.class, true));
        cmds.add(new CliCmdEntity(false,"r", "registryHosts", true, "Registry hosts, Multiple are separated by ‘|’.", String.class, true));
        cmds.add(new CliCmdEntity(false,"hp", "httpdPort", true, "Http server port.", Integer.class, true));
        cmds.add(new CliCmdEntity(false,"hh", "httpdHost", true, "Http server host.", String.class, true));
        cmds.add(new CliCmdEntity(false,"x", "ioThreads", true, "IO thread count.", Integer.class, true));
        cmds.add(new CliCmdEntity(false,"y", "workerThreads", true, "Worker thread count.", Integer.class, true));
        //以下为manage特有，client不能带入
        cmds.add(new CliCmdEntity(false,"u", "autoUpdate", false, "auto update client.", Boolean.class, false));
        cmds.add(new CliCmdEntity(false,"c", "cpu", true, "Cpu use occupancy.", Integer.class, false));
        cmds.add(new CliCmdEntity(false,"br", "baudRate", true, "com port baud rate.", Integer.class, false));
        cmds.add(new CliCmdEntity(false,"em", "enableManage", false, "Enable com manager.", Boolean.class, false));
        return cmds;
    }

    public static List<String> getExludeCmds(){
        List<String> exludes = new ArrayList<>();
        List<CliCmdEntity> cmds = getCmds();
        for (CliCmdEntity cce : cmds){
            if(!cce.isJoin()){
                exludes.add(cce.getShortOpt());
                exludes.add(cce.getLongOpt());
            }
        }
        return exludes;
    }

    public static boolean hasArgs(String opt){
        boolean isHas = false;
        List<CliCmdEntity> cmds = getCmds();
        for (CliCmdEntity entity : cmds){
            if(entity.getShortOpt().equals(opt) || entity.getLongOpt().equals(opt)){
                isHas = entity.isHasArg();
                break;
            }
        }
        return isHas;
    }
}
